using System;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder;
using Microsoft.Practices.ObjectBuilder2;

namespace Common.Core.Configuration
{
	public class NameTypeSettingsAssembler<TObject, TConfiguration> : IAssembler<TObject, TConfiguration>
		where TObject : class
		where TConfiguration : NameTypeConfigurationElement
	{
		public virtual TObject Assemble( IBuilderContext context, TConfiguration objectConfiguration,
		                         IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache )
		{
			return (TObject)Activator.CreateInstance( objectConfiguration.Type );
		}
	}
}